import {
  RightsCreateDto,
  RightsFindDto,
  RightsInvoiceDispatchDto,
  RightsInvoiceQueryDto,
  RightsListDto,
  RightsQueryDto,
  RightsUpdateDto,
} from '@/dtos';
import { RightsService } from '@/services/rights.service';
import { ok } from '@/utils';
import { Body, Controller, Patch, Post } from '@nestjs/common';
import { BaseController } from './base.controller';

@Controller('rights')
export class RightsController extends BaseController {
  constructor(private readonly rightsService: RightsService) {
    super();
  }

  @Post('list')
  async list(@Body() dto: RightsListDto) {
    return ok(await this.rightsService.list(dto));
  }

  @Post('admin/query')
  async query(@Body() dto: RightsQueryDto) {
    return ok(await this.rightsService.query(dto));
  }

  @Post('admin/find')
  async find(@Body() dto: RightsFindDto) {
    return ok(await this.rightsService.findOne(dto.where, dto.select));
  }

  @Post('admin/create')
  async create(@Body() dto: RightsCreateDto) {
    return ok(await this.rightsService.create(dto.data));
  }

  @Patch('admin/update')
  async update(@Body() dto: RightsUpdateDto) {
    return ok(await this.rightsService.update(dto));
  }

  @Post('admin/invoice')
  async invoice(@Body() dto: RightsInvoiceQueryDto) {
    return ok(await this.rightsService.invoice(dto));
  }

  @Patch('admin/dispatch')
  async dispatch(@Body() dto: RightsInvoiceDispatchDto) {
    return ok(await this.rightsService.dispatch(dto));
  }
}
